use std::path::PathBuf;

pub fn test_logger() -> Result<(), Box<dyn std::error::Error>> {
    // 获取当前目录
    let current_dir = std::env::current_dir()?;
    println!("Current directory: {}", current_dir.display());
    
    // 构建日志配置文件路径
    let log_config_path = current_dir.join("config/log4rs.yaml");
    println!("Log config path: {}", log_config_path.display());
    
    // 检查配置文件是否存在
    if log_config_path.exists() {
        println!("Log config file exists");
    } else {
        println!("Log config file does not exist");
    }
    
    // 初始化日志系统
    match log4rs::init_file(&log_config_path, Default::default()) {
        Ok(_) => {
            println!("Log system initialized successfully");
            
            // 测试各种日志级别
            log::trace!("This is a trace message");
            log::debug!("This is a debug message");
            log::info!("This is an info message");
            log::warn!("This is a warning message");
            log::error!("This is an error message");
            
            Ok(())
        },
        Err(e) => {
            println!("Failed to initialize log system: {}", e);
            Err(Box::new(e))
        }
    }
}